package com.skaura.cryserver.handler;

import com.alibaba.fastjson.JSONObject;
import com.skaura.cryserver.model.MessageWapper;
import com.skaura.cryserver.model.TestDto;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.SimpleChannelInboundHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.InetSocketAddress;
import java.nio.Buffer;

public class CustomHandler extends SimpleChannelInboundHandler {
    Logger logger = LoggerFactory.getLogger(CustomHandler.class);
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, Object o) throws Exception {
        if (o instanceof MessageWapper){
            MessageWapper messageWapper = (MessageWapper) o;
            logger.info(JSONObject.toJSONString(messageWapper));
            ByteBuf byteBuf = Unpooled.buffer(1024);
            ctx.writeAndFlush(messageWapper);
        }
    }

}
